import { Message } from '@arco-design/web-react';
import { apiSyncOperateStartAndStop } from '../../../api';
import { CardDetail } from '../refresh/types';
import LoadingMask from '../../../components/loadingMask';
// 开关机
export async function handleOpenOrStop(record: CardDetail,callBack?: Function) {
    LoadingMask.show('正在操作...');
    try {
      let res = await apiSyncOperateStartAndStop({
        iccid: record.iccid,
        ids:record.id,
        updateStatus: record.cardStatus === '3' ? '4' : '3',
      });
      let data = res.data;
      if (data.code === 200) {
        Message.success(data.msg ?? '操作成功');
        callBack && callBack()
      } else {
        Message.warning(data.msg ?? '操作失败');
      }
    } catch (e: any) {
      Message.error(e.message ?? '操作失败');
    } finally {
      LoadingMask.hide();
    }
  }